package com.java2_20;

public class Student {
    protected String name;
    protected int age;

    protected void show(){
        System.out.println("protected测试");
    }

    public Student(){

    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    //protected可以直接在本类中调用
    public void setAge(int age) {
        if(age < 18 || age >40){
            throw new RuntimeException();
        }
        this.age = age;
    }
}
